Skip to content

feat(clearinghouse): modular perps as CLOB consumer#133

Open
JaeLeex wants to merge 8 commits into
mainfrom
jl/clearinghouse-perps-modular
Open

feat(clearinghouse): modular perps as CLOB consumer#133
JaeLeex wants to merge 8 commits into
mainfrom
jl/clearinghouse-perps-modular

Conversation

@JaeLeex

@JaeLeex JaeLeex commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds nunchi-clearinghouse — routes matched CLOB fills to perpetuals via RegisterPerpsMarket + SettleFill / CommitAndSettleFill
  • Refactors nunchi-perpetuals to open/close positions through apply_fill_settlement (CLOB fill path); gates direct OpenPosition/ClosePosition behind mock-execution
  • Wires CLOB + clearinghouse into examples/coins-chain (TX_CLOB=4, TX_CLEARINGHOUSE=5) with cross-validator integration test

Supersedes #79 and #80 with the modular architecture from the Jul 10 standup:

CLOB → Fill → Clearinghouse → Perps (positions) + Coins (collateral)
Perps → orders on linked CLOB market

Test plan

  • cargo test -p nunchi-clearinghouse
  • cargo test -p nunchi-perpetuals --features mock-execution
  • cargo test -p nunchi-coins-chain --test coins perps_clob_clearinghouse
  • Full CI on PR

Made with Cursor

JaeLeex and others added 6 commits July 6, 2026 17:16
Add the standalone CLOB primitive ahead of perps wiring so spot and derivatives can share deterministic market, order, matching, and fill state without embedding book logic in consumers.

Co-authored-by: Cursor <cursoragent@cursor.com>
Canonicalize asset pairs in market_id, expose programmatic place_order,
prune terminal account_orders entries, and document the no-STP policy.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add nunchi-memclob for validator-local order gossip, ClobOperation::CommitFill
for on-chain fill settlement, and a SettlementBridge that drains memclob fills
into the mempool for proposer inclusion on coins-chain.

Co-authored-by: Cursor <cursoragent@cursor.com>
Introduce nunchi-clearinghouse to route matched CLOB fills into perpetuals,
refactor perps to settle positions via apply_fill_settlement, and wire both
modules into coins-chain with an end-to-end integration test.

Co-authored-by: Cursor <cursoragent@cursor.com>
Restore main CI workflow, box large memclob/clearinghouse message variants,
allow perps clippy exceptions, and submit mempool replacement before consensus.

Co-authored-by: Cursor <cursoragent@cursor.com>
Reconcile with main's CLOB actor/extension, bridge module, coins-chain
path move, and mempool API while keeping clearinghouse + perpetuals wiring.
All 298 workspace tests pass locally after updating integration tests for
off-chain CLOB semantics and CommitAndSettleFill settlement flow.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add perpetuals genesis roundtrip/apply tests and a clearinghouse
settlement batch builder test. Extend coins-chain test network with
CLOB actor sync helpers for future live mailbox integration.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add RPC and transaction codec roundtrip tests plus memclob rejection coverage.
Gate mock-execution-only close_position tests so perpetuals compiles standalone.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant